﻿<%@ Page Language="C#" MasterPageFile="~/Common.Master" AutoEventWireup="true" CodeBehind="Reg.aspx.cs"
    Inherits="com.tiyma.web.User.Reg" Title="体验码小说网,用户注册" %>

<asp:Content ID="c1" ContentPlaceHolderID="phContent" runat="server">
    <link href="/style/usercenter.css" rel="stylesheet" type="text/css" />

    <script src="/javascript/ajax.js" type="text/javascript"></script>

    <div class="wrapper">
        <div class="reg">
            <div class="pos">
                用户中心&gt; <b>注册</b></div>
            <div class="bx">
                <div class="bar">
                    填写注册信息</div>
                <div class="ct">
                    <div class="regform">
                        <table cellspacing="0" cellpadding="0">
                            <tbody>
                                <tr>
                                    <th>
                                        <label>
                                            用 户 名：</label>
                                    </th>
                                    <td class="c1">
                                        <input id="txtUserName" class="textbox" type="text" name="username" onblur="CheckUser()" /><span class="note" id="spNote" />您登录时使用的用户ID，2至16位的英文和数字</span>
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        <label>
                                            密 码：</label>
                                    </th>
                                    <td class="c1">
                                        <input class="textbox" id="txtPassword" type="password" name="password"><span class="note"></span>
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        <label>
                                            重复密码：</label>
                                    </th>
                                    <td class="c1">
                                        <input class="textbox" type="password" id="txtVerfyPassword" name="verifypass" /><span
                                            class="note"></span>
                                    </td>
                                </tr>
                                <tr id="divEmail">
                                    <th>
                                        <label>
                                            邮 件：</label>
                                    </th>
                                    <td class="c1">
                                        <input class="textbox" id="txtEmail" maxlength="100" type="text" name="email" />
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                    </th>
                                    <td class="c1">
                                        <p class="vcode">
                                            <img id="vcodeImg" src="/v.aspx?" width="120" height="38" />
                                            <a onclick="javascript:document.getElementById('vcodeImg').src=document.getElementById('vcodeImg').src+'?';"
                                                href="javascript:void(0);">看不清？换一张</a></p>
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        <label>
                                            验 证 码：</label>
                                    </th>
                                    <td class="c1">
                                        <input id="txtVcode" class="textbox" type="text" name="vcode" /><span class="note">请填写上面图片显示的文字</span>
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                    </th>
                                    <td class="c2">
                                        <p class="rule">
                                            <input id="agree" class="checkbox" checked type="checkbox" name="agree">我已阅读关于体验码小说网帮助说明<a
                                                title="《关于体验码小说网帮助说明》" href="/help.aspx" target="_blank">《关于体验码小说网帮助说明》</a></p>
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                    </th>
                                    <td class="c2">
                                        <input class="button" onclick="javascript:return Reg();" value="提交注册" />&nbsp;&nbsp;&nbsp;&nbsp;<input
                                            class="button" value="重 置" onclick="javascript:return Reset();" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="rec">
                        <div class="gpk2">
                            <dl>
                                <dt>注册成为“体验码”的用户后，您可以：</dt>
                                <dd>
                                    <ul>
                                        <li>方便把喜欢的小说存入<b class="hl">我的书架</b>管理<b class="hl">最近阅读</b>信息。</li>
                                        <li>方便得到小说<b class="hl">更新提醒</b>，分享小说书评。</li>
                                        <li>可以“<b class="hl">点读</b>”小说</li>
                                        <li>……</li>
                                    </ul>
                                </dd>
                            </dl>
                        </div>
                    </div>
                </div>
            </div>
            <div class="fthr">
            </div>
        </div>
    </div>

    <script>
       var u=$("txtUserName");
       var p1=$("txtPassword");
       var p2=$("txtVerfyPassword");
       var email=$("txtEmail");
       var v=$("txtVcode");
       var returnUrl="<%=m_return_url %>";
       function isEmail(str)
       { 
            res = /^[0-9a-zA-Z_\-\.]+@[0-9a-zA-Z_\-]+(\.[0-9a-zA-Z_\-]+)*$/; 
            var re = new RegExp(res); 
            return !(str.match(re) == null); 
        } 
        function CheckUser()
        {
            $("spNote").innerHTML="您登录时使用的用户ID，2至16位的英文和数字";
            if(u.value=="")
            {
                return false;
            }
             MyAjax.ExcuteScript("checkuser",u.value,ShowCheckBack);
              
                
        }
        function ShowCheckBack(result)
        {
            if(result.value.indexOf("有效")>-1)
            {
                $("spNote").innerHTML="<font color=\"green\">"+result.value+"</font>";
            }
            else
            {
                 $("spNote").innerHTML="<font color=\"red\">"+result.value+"</font>";
            }
        }
        function Reset()
        {
            u.value="";
            p1.value="";
            p2.value="";
            email.value="";
            v.value="";
            $("vcodeImg").src="/v.aspx?t="+new Date().getDate();
        }
        function Reg()
        {
           if($("spNote").innerHTML.indexOf("有效")<0)
           {
             alert("用户名无效!");
             u.focus();
             return false;
           }
           if(u.value=="" || u.value.length<2 || v.value.length>16)
           {
             u.focus();
             alert("用户名不符合规范!");
             return false;
           }
           if(p1.value=="" || p1.length<6)
           {
            alert("密码不能为空，长度不能小于6位!");
            p1.focus();
            return false;
           }
           if(p1.value!=p2.value)
           {
             p2.focus();
             alert("两次密码不一致!");
             return false;
           }
           if(v.value=="")
           {
            v.focus();
            alert("请输入验证码!");
            return false;
           }
           if(isEmail(email.value)==false)
           {
            email.focus();
            alert("邮箱格式不正确!");
            return false;
           }
            var script=u.value+"$"+p1.value+"$"+email.value+"$"+v.value;
            MyAjax.ExcuteScript("register",script,ShowBack);
       }
       function ShowBack(result)
        {
            if(result.value.indexOf("成功")>-1)
            {
                window.location.href=returnUrl;
            }
            else
            {
                alert(result.value);
            }
        }
    </script>

</asp:Content>
